<template>
  <div>
    <v-card-title>
      <h3>Salt任务表</h3>
      <v-spacer></v-spacer>
      <v-btn flat color="primary" icon @click.stop="handlerReturns" small><v-icon>cached</v-icon></v-btn>
      <v-text-field
        append-icon="search"
        label="Search"
        single-line
        hide-details
        v-model="search"
      ></v-text-field>
    </v-card-title>
    <v-data-table
            :headers="headers"
            :items="items"
            :pagination.sync="pagination"
            :total-items="totalItems"
            :loading="loading"
            :rows-per-page-items="rowsPerPageItems"
            :no-data-text="etext"
            class="elevation-1">
      <template slot="items" slot-scope="props">
        <td class="datastyle" v-for="(value) in headers" :key="value.jid">{{props.item[value.value]}}</td>
      </template>
    </v-data-table>
  </div>
</template>

<script>
import { createNamespacedHelpers } from 'vuex'
const { mapActions } = createNamespacedHelpers('listreturns')
export default {
  name: 'listreturns',
  data: function () {
    return this.$store.state.listreturns
  },
  watch: {
    pagination: function () {
      this.handlerReturns()
    },
    search: function () {
      this.handlerReturns()
    }
  },
  methods: {
    ...mapActions({
      handlerReturns: 'handlerReturns',
      loadReturnsHeaders: 'loadReturnsHeaders'
    })
  },
  mounted () {
    this.loadReturnsHeaders()
  }
}
</script>
